public class Complex {
    double RealPart;
    double ImagePart;
    public Complex(){}
    public Complex(double R,double I){
        RealPart=R;
        ImagePart=I;
    }
    public boolean equals(Complex a){
        if(a.RealPart==this.RealPart&&a.ImagePart==this.ImagePart){
            return true;
        }
        else {
            return false;
        }
    }
    public String toString(){
        return "Complex{"+RealPart+","+ImagePart+"}";
    }
    Complex ComplexAdd(Complex a) {
        return new Complex(this.RealPart + a.RealPart,this.ImagePart + a.ImagePart);
    }
    Complex ComplexSub(Complex a){
        return new Complex(this.RealPart - a.RealPart,this.ImagePart - a.ImagePart);
    }
    Complex ComplexMulti(Complex a){
        return new Complex(this.RealPart*a.RealPart-this.ImagePart*a.ImagePart,
                this.ImagePart*a.RealPart+this.RealPart*a.ImagePart);
    }
    Complex ComplexDiv(Complex a){
        double change = a.RealPart*a.RealPart + a.ImagePart*a.ImagePart;
        Complex b = new Complex(a.RealPart / change, - a.ImagePart / change);
        return this.ComplexMulti(b);
    }

} 
